<#include "/layout/layout.ftl">
<#import "/layout/macro.ftl" as macro>
<#import "/layout/select.ftl" as my/>
<#assign css>
<#--此ftl中用到的css-->
</#assign>
<#assign js>
<#--此ftl中用到的js-->
<script>
	$(".btn-submit").click(function () {
		// 校验表单合法
		var bootstrapValidator = $(".form-edit").data('bootstrapValidator');
		bootstrapValidator.validate();
		if(bootstrapValidator.isValid()){
			$.ajax({
				type: "POST",
				url: "/message/edit",
				data: $(".form-edit").serialize(),
				dataType: "JSON",
				success: function(res){
					layer.msg(res.message, {time: 2000
					}, function(){
						location.href="/message/index";
					});
				}
			});
		}else{
			return false;
		}
	});

	$('.form-edit').bootstrapValidator({
		message: '请输入有效值',
		feedbackIcons: {
			valid: 'glyphicon glyphicon-ok',
			invalid: 'glyphicon glyphicon-remove',
			validating: 'glyphicon glyphicon-refresh'
		}
	});

	$("#choose_user").click(function () {
        $('#myModal').modal();
    });

</script>
</#assign>
<@layout title="编辑" active="message">
<!-- Content Header (Page header) -->
<section class="content-header">
	<h1>
		<#if isAdd>
            新增
        <#else>
            编辑
        </#if>
		<small>消息详细信息</small>
	</h1>
	<ol class="breadcrumb">
		<li><a href="/"><i class="fa fa-home"></i> 管理后台</a></li>
		<li><a href="#"><i class="fa fa-list-ul"></i> 消息管理</a></li>
		<li class="active"><i class="fa fa-edit"></i>
		    <#if isAdd>
                新增
            <#else>
                编辑
            </#if>
		</li>
	</ol>
</section>
<!-- Main content -->
<section class="content">

    <#--<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">新增</h4>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label for="txt_departmentname">部门名称</label>
                        <input type="text" name="txt_departmentname" class="form-control" id="txt_departmentname" placeholder="部门名称">
                    </div>
                    <div class="form-group">
                        <label for="txt_parentdepartment">上级部门</label>
                        <input type="text" name="txt_parentdepartment" class="form-control" id="txt_parentdepartment" placeholder="上级部门">
                    </div>
                    <div class="form-group">
                        <label for="txt_departmentlevel">部门级别</label>
                        <input type="text" name="txt_departmentlevel" class="form-control" id="txt_departmentlevel" placeholder="部门级别">
                    </div>
                    <div class="form-group">
                        <label for="txt_statu">描述</label>
                        <input type="text" name="txt_statu" class="form-control" id="txt_statu" placeholder="状态">
                    </div>
                </div>
                <div class="box-footer clearfix">
                    <@macro.page pageInfo=pageInfo url="/message/index?" />
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭</button>
                    <button type="button" id="btn_submit" class="btn btn-primary" data-dismiss="modal"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>保存</button>
                </div>
            </div>
        </div>
    </div>-->

	<div class="row">
		<div class="col-md-12">
			<!-- Default box -->
			<div class="box  box-primary">
				<form class="form-horizontal form-edit" method="post" action="message/edit">
					<div class="box-body">
						<input type="hidden" id="id" name="id" value="${message.id!}">
						<input type="hidden" id="isAdd" name="isAdd" value="${isAdd?string('true','false')}">
                        <#if isAdd>
                            <#--<button id="choose_user">选择用户</button>-->
                            <div class="form-group">
                                <label class="col-sm-2 control-label">用户：</label>
                                <div class="col-sm-10">
                                    <input required placeholder="请输入用户手机号" id="phone" name="phone" class="form-control" type="text" value="" >
                                </div>
                            </div>
                        <#else>
                            <input id="userId" name="userId" class="form-control" type="hidden" value="${message.userId!}" >
                        </#if>

						<#--<div class="form-group">
							<label class="col-sm-2 control-label">用户类型：</label>
							<div class="col-sm-10">
                                <@my.select id="userType" datas=getDict('USER_TYPE')  value="${message.userType!}" defaultValue="请选择用户类型"/>
							</div>
						</div>-->
						<div class="form-group">
							<label class="col-sm-2 control-label">消息类型：</label>
							<div class="col-sm-10">
                                <@my.select id="type" datas=getDict('MESSAGE_TYPE')  value="${message.type!}" defaultValue="请选择消息类型"/>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">消息标题：</label>
							<div class="col-sm-10">
								<input required placeholder="请输入消息标题" id="title" name="title" class="form-control" type="text" value="${message.title!}" >
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">副标题：</label>
							<div class="col-sm-10">
								<input required placeholder="请输入副标题" id="subtitle" name="subtitle" class="form-control" type="text" value="${message.subtitle!}" >
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">消息内容：</label>
							<div class="col-sm-10">
								<input required placeholder="请输入消息内容" id="content" name="content" class="form-control" type="text" value="${message.content!}" >
							</div>
						</div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">是否发送：</label>
                            <div class="col-sm-10">
                                <input id="isPush" name="isPush" type="checkbox" checked="checked" />
                            </div>
                        </div>

					<div class="box-footer">
						<button type="button" class="btn btn-default btn-back">返回</button>
						<button type="button" class="btn btn-info pull-right btn-submit">提交</button>
					</div>

				</form>
			</div>
			<!-- /.box -->
		</div>
	</div>
</section>
<!-- /.content -->
</@layout>
